<?php
include('rootlogin.php');
//include('../incsession.php');
session_start();
$err=0;
if($_POST['submit']=="submit"){
	$str=str_replace($_POST['keyword'], "", $_POST['dict'], $count);
	if($count>1){
		$err=1;	
	}
	else if($count<1){
		$err=2;	
	}
	else{
		
		
		$query = "UPDATE system 
					SET dict='".$_POST['dict']."', 
				    	keyword='".$_POST['keyword']."'";
		$result = mysql_query($query,$user_con);
	}
}
if($_POST['submit']=="back to index"){
	header("location: index.php");
}


?>

<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="framestyle.css" type="text/css" media="screen">
<style type="text/css">

</style>
</head>


<body>

<div id="wrapper">
<div id="title">Online Listening Comprehension Program</div>

<div id="main">
<hr/>
<div id="title2">CHANGE THE DICTIONARY</div>
<div id="title3">
1. Look up a word in an online dictionary<br>
2. Type the word you looked up in the row "keyword"<br>
3. Copy the result URL after you look up the word, and paste it in the row "dicitonary URL"
</div>

<hr/>
<br><br>
<form method = POST action="dict.php">
<?php
if($err==1){
	echo "<div id='error'>Error. Please try to look up another word. The word appears twice in the URL.</div><br>";	
}
else if($err==2){
	echo "<div id='error'>Error. The keyword does not correspond to the URL.</div><br>";	
}

?>
current dictionary:
<?php


$query = "SELECT dict, keyword FROM system";
$result = mysql_query($query,$user_con);
$row = mysql_fetch_array($result);
echo "<a href='".$row['dict']."'>".$row['dict']."</a>";
?>
<br><br>
<table>
<tr><td align="right">keyword:<td><input class="area short" type="text" name="keyword">
<tr><td align="right">dictionary URL:<td><input class="area long" type="text" name="dict">
</table>
<br><br>
<div class="btn_right"><input type="submit" name = "submit" value = "submit"></div><br>
<div class="btn_right"><input type="submit" name = "submit" value = "back to index"></div>
</form>
</div>
</div>
</body>

